import { axios } from "../../request";
Page({
  data: {
    swiperList: [],
    catitemsList: [],
    floordata:[],
  },
  // 获取导航
  getClassify() {
    axios({
      url: "/home/catitems"
    }).then(res => {
      // console.log("res: ", res.message);
      this.setData({
        catitemsList: res.message
      });
    });
  },
  // 获取轮播图
  getBanner() {
    axios({
      url: "/home/swiperdata"
    }).then(res => {
      const { message } = res;
      // console.log('message: ', message);
      this.setData({
        swiperList: message
      });
    });
  },
  // 获取楼层
  getFloordata(){
    axios({
      url:"/home/floordata"
    }).then(res=>{
      const floordata = res.message.map((item,index)=>{  
        return  {...item, id:index } 
      })
      // console.log('floordata: ', floordata);
      this.setData({
        floordata:floordata
      })

    })
  },
  onLoad() {
    this.getBanner();
    this.getClassify();
    this.getFloordata();
  }
});
